package cn.tedu.icop.basic.controller;
import cn.tedu.icop.api.model.RestResult;
import cn.tedu.icop.api.model.RestResultUtils;
import cn.tedu.icop.basic.pojo.StationPO;
import cn.tedu.icop.basic.pojo.StationVO;
import cn.tedu.icop.basic.service.StationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/basic")
@Api(tags = "设备接口")
public class StationController {

    @Autowired
    private StationService stationService;

    @ApiOperation("附近充电站")
    @GetMapping("/station/near")
    public RestResult<List<StationVO>> getNearStationList(Double longitude, Double latitude, Double radius) {
        log.debug("获取附近充电站入参 经度:{},维度:{},距离(范围):{}",longitude,latitude,radius);
        List<StationVO> list = stationService.getNearStationList(longitude,latitude,radius);
        return RestResultUtils.success(list);
    }

    @ApiOperation("获取场站信息")
    @GetMapping("/station/info/{id}")
    public RestResult<StationVO> getStationInfo(@PathVariable("id") Integer id) {
        log.debug("获取场站信息:{}",id);
        StationVO stationVO = stationService.getStation(id);
        RestResult ok = RestResultUtils.success(stationVO);
        log.debug("获取场站信息:{},出参:{}",id,ok);
        return ok;
    }
}
